using System;
using System.Data;
using System.Linq;
using Easy.Model;
using Easy.Data;
using Easy.Service.DataAccess;
using System.Collections.Generic;

namespace Easy.Service.Business
{
    /// <summary>
    /// 考勤业务层
    /// </summary>
    public class MediaBusiness
    {
        /// <summary>
        /// 添加考勤
        /// </summary>
        public static void AddMedia(MediaModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            model.MediaCreateTime = DateTime.Now;
            model.MediaLastTime = DateTime.Now;
            MediaDataAccess.AddMedia(model);
        }

        /// <summary>
        /// 修改考勤
        /// </summary>
        public static void UpdateMedia(MediaModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            model.MediaLastTime = DateTime.Now;
            MediaDataAccess.UpdateMedia(model);
        }

        /// <summary>
        /// 审批考勤
        /// </summary>
        public static void ApproveMedia(MediaModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            if (model.MediaApproveState.Equals("02"))
            {
                model.MediaApproveRemarks = " ";
            }
            model.MediaLastTime = DateTime.Now;
            MediaDataAccess.UpdateMedia(model);
            SendMessage(model.MediaId);
        }

        /// <summary>
        /// 查询考勤
        /// </summary>
        public static DataPage SearchMedia(SearchMediaModel model)
        {
            return MediaDataAccess.SearchMedia(model);
        }

        private static void SendMessage(string mediaId)
        {
            // 发送消息的实现
        }
    }
}